<template>

  <div class="bg-f5f5f5">
      <div class="home-bar page-bar position-fixed ">
        
        
        <mt-header title="">
       
          <mt-button @click="goback" icon="back" class="font-size-18" style='font-size:18px;' slot="left">历史记录</mt-button>
       
          <mt-button icon="back"></mt-button>
        
     
      </mt-header>
      </div>
   

    <div class="height-56"></div>
      
          
                <div  v-for="item in NewNewsArrSessionStorageArr" @click="stateGohomeDetailsDialogBox(item)">
                  <div class="home-list bg-ffffff overflow-hidden "  style="margin:4px 0;">
                      <div class=" width100">
                              <div class="display-inline-block list-left position-relative home-list-img-div">
                                  <img  v-bind:src="doctorImg(item)"  :onerror="SpareImg()" class=" home-list-img">
                            </div>
                            <div class="display-inline-block position-relative list-right home-list-img-div float-right" >
                                  <div class="font-size-13" style="text-align:left;width:82%;margin-top:12px;;">
                                      <div class="color-333333">{{item.name}}</div>
                                      <div class="color-888888 overflow-hidden text1-hide"  style="width:130px;">{{item.content}}</div>
                            </div>

                                  <div class="position-absolute font-size-13 color-666666" style="right:0;top:20px;">{{item.time}}</div>
                            </div>
                    </div>
                   
                  </div>
                   <div style="height:2px;"></div>
                </div>    

                  <div v-if="NewNewsArrSessionStorageArr.length==0" class="color-888888 text-align-center" style="margin:20% 0;">暂无内容</div>
          
  </div>
</template>

<script>

import { Header } from 'mint-ui';
import Vue from 'vue';
import AppVue from '../App';
import config from '../config/config.js';



Vue.component(Header.name, Header);

export default {
  name: 'homeHistory',
  data () {
    return {
      msg: 'homeHistory',
       NewNewsArrSessionStorageArr:JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorage"))?JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorage")):'',
      homeListArr:[
         {
            name:'吴东彦1',
            address:'城关镇芙蓉社区1号团队',
            title:'临床医生',
            img:'/static/img/houyangna.png',

         },
          {
            name:'吴东彦2',
            address:'城关镇芙蓉社区1号团队',
            title:'临床医生',
            img:'/static/img/houyangna.png',

         },
          {
            name:'吴东彦3',
            address:'城关镇芙蓉社区1号团队',
            title:'临床医生',
            img:'/static/img/houyangna.png',

         },
          {
            name:'吴东彦4',
            address:'城关镇芙蓉社区1号团队',
            title:'临床医生',
            img:'/static/img/houyangna.png',

         },
          {
            name:'吴东彦5',
            address:'城关镇芙蓉社区1号团队',
            title:'临床医生',
            img:'/static/img/houyangna.png',

         },
         
         ],
    }
  },
   mounted(){
          //console.log('___')
          //console.log(AppVue.methods.NewNews)
          //调用父级方法
          AppVue.methods.NewNews();
          //console.log('history页面');
         

          // console.log(this.NewNewsArrSessionStorageArr);
          // console.log('____');
   },
    //销毁完成状态
   destroyed(){
     config.scrollTopFunName(); 
   
   },
   methods:{
      
        goback(){
          this.$router.go(-1);
      },

      //跳转=> 对话框
      stateGohomeDetailsDialogBox(item){
           
            //if(config.isIosPlatform==false){
            //安卓
            this.$router.push({ path: '/homeDetailsDialogBox',name:'homeDetailsDialogBox',params:{itemObj:item}});
           //}else{
            //ios
            //  this.$router.replace({ path: '/homeDetailsDialogBox',name:'homeDetailsDialogBox',params:{itemObj:item}});
           //}  

           //为了兼容IOS端的微信浏览器 只能用储存标记 在医生列表详情点击时 清除
           window.sessionStorage.setItem("NewNewsArrSessionStorageSign",JSON.stringify(item));
           
      },

      //获取当前历史记录列表
      ObtainNewNewsArrSessionStorageArr(){
          this.NewNewsArrSessionStorageArr=JSON.parse(sessionStorage.getItem("NewNewsArrSessionStorage"));
          //判断头像
                    
      },
      doctorImg(str){
      
        let homeListDoctorArr1Storage=(JSON.parse(sessionStorage.getItem("homeListDoctorArr1")));
        for(let i in homeListDoctorArr1Storage){
            if(homeListDoctorArr1Storage[i].id==str.id){
                 return config.ObtainDoctorListDoctorImgSplicing+homeListDoctorArr1Storage[i].photo_url;
            }
        }
        
      },

      //图片错误是备用图片
        SpareImg(){
          return 'this.src="' + require('../assets/yisheng.png') + '"';
          
      },
      

     
   },
    props:{
          //父级传过来的值
          OverallSituation:'',
    },
    watch:{
        OverallSituation(curVal,oldVal){
            console.log('监听');
            console.log(curVal);
            if(curVal.length){
                if(curVal.length!=0){
                this.ObtainNewNewsArrSessionStorageArr();
                }else{
                    console.log('无变化')
                }        
            }
            
            // console.log(oldVal);
        },
      
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
    .home-title{
        font-size:19px;
        margin-top:16px;
    }
    .title-left{
        left:6px;
        top:18px;
        
    }
    .title-right{
        right:6px;
        top:18px;
        
    }
    .home-list{
      height:60px;
      
      padding:0 12px;
    }
    .list-left{
      width:18%;
    }

    .list-right{
      width:80%;
    }
    .home-list-img-div{
      height:60px;
      text-align:center;
     
      
    }
    .home-list-img{
        width:50px;
         margin-top:0px;
    }
   .mint-header{
  height:56px;
   background: -webkit-linear-gradient(left, #1de5e2, #b588f7) !important;
   
}
</style>
